﻿namespace btmerc.API.Schemas
{
    public partial class TroopCount
    {
        public TroopCount(TroopCount originalCount, TroopCount removedCount)
        {
            AeroCapacity = originalCount.AeroCapacity < removedCount.AeroCapacity ? (ushort)0 : (ushort)(originalCount.AeroCapacity - removedCount.AeroCapacity);
            BattleArmorCapacity = originalCount.BattleArmorCapacity < removedCount.BattleArmorCapacity ? (ushort)0 : (ushort)(originalCount.BattleArmorCapacity - removedCount.BattleArmorCapacity);
            BattlemechCapacity = originalCount.BattlemechCapacity < removedCount.BattlemechCapacity ? (ushort)0 : (ushort)(originalCount.BattlemechCapacity - removedCount.BattlemechCapacity);
            CargoCapacity = originalCount.CargoCapacity < removedCount.CargoCapacity ? (ushort)0 : (ushort)(originalCount.CargoCapacity - removedCount.CargoCapacity);
            HeavyVehicleCapacity = originalCount.HeavyVehicleCapacity < removedCount.HeavyVehicleCapacity ? (ushort)0 : (ushort)(originalCount.HeavyVehicleCapacity - removedCount.HeavyVehicleCapacity);
            TroopCapacity = originalCount.TroopCapacity < removedCount.TroopCapacity ? (ushort)0 : (ushort)(originalCount.TroopCapacity - removedCount.TroopCapacity);
            VehicleCapacity = originalCount.VehicleCapacity < removedCount.VehicleCapacity ? (ushort)0 : (ushort)(originalCount.VehicleCapacity - removedCount.VehicleCapacity);
        }

        public bool HasTroops()
        {
            return (AeroCapacity + BattleArmorCapacity + BattlemechCapacity + HeavyVehicleCapacity + TroopCapacity + VehicleCapacity) > 0;
        }

        public ushort CombinedTroopCount
        {
            get
            {
                return (ushort)(AeroCapacity + BattleArmorCapacity + BattlemechCapacity + HeavyVehicleCapacity + TroopCapacity + VehicleCapacity);
            }
        }
    }
}
